﻿using System;
using System.Diagnostics;
using AutoMapper;
using Soundteller.Application.Facade.Contracts;
using Soundteller.Application.Facade.Interfaces;
using Soundteller.Visual.Repositories.Interfaces;
using Soundteller.Visual.Services.Interfaces;

namespace Soundteller.Application.Facade
{
    public class VisualFacade : IVisualFacade
    {
        private readonly IGraphicBufferRepository _graphicBufferRepository;

        public VisualFacade(IGraphicBufferRepository graphicBufferRepository)
        {
            if (graphicBufferRepository == null) throw new ArgumentNullException("graphicBufferRepository");

            _graphicBufferRepository = graphicBufferRepository;
        }

        public XnaGraphic PeekGraphicBuffer()
        {
            Debug.WriteLine("{0}.PeekGraphicBuffer()", GetType().Namespace, null);

            return Mapper.Map<XnaGraphic>(_graphicBufferRepository.Peek());
        }

        public XnaGraphic PopGraphicBuffer()
        {
            Debug.WriteLine("{0}.PopGraphicBuffer()", GetType().Namespace, null);

            return Mapper.Map<XnaGraphic>(_graphicBufferRepository.Pop());
        }
    }
}
